//package cn.flying.cloud.common;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.UUID;
//
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import cn.flying.cloud.base.common.vo.Rt;
//import cn.flying.cloud.file.api.FileServiceApi;
//import cn.flying.cloud.file.model.FileRequest;
//import cn.flying.cloud.message.api.MessageServiceApi;
//import cn.flying.cloud.message.model.MessageRequest;
//import cn.flying.cloud.tool.ops.instance.websocket.TopicInstancePush;
//
///**
// * @author: admin
// * @date: 2025年04月07日 09:45
// * @version: 1.0
// */
//@RestController
//@RequestMapping("demo")
//public class DemoController {
//
//    @DubboReference
//    private FileServiceApi fileServiceApi;
//    @DubboReference
//    private MessageServiceApi messageServiceApi;
//
//    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
//    public Rt<?> upload(@RequestParam("file") MultipartFile file, @RequestParam("bucket") String bucketName) throws IOException {
//        FileRequest req = new FileRequest();
//        req.setTenantId("10000");
//        req.setRequestNo(UUID.randomUUID().toString().replaceAll("-", ""));
//        req.setServiceCode("admin");
//        req.setBucketName(bucketName);
//        req.setFileName(file.getOriginalFilename());
//        req.setContent(file.getBytes());
//
//        String upload = fileServiceApi.upload(req);
//
//        return Rt.success("上传成功", upload);
//    }
//
//    @PostMapping(value = "/sendMail")
//    public void sendMail() {
//        MessageRequest req = new MessageRequest();
//        req.setTenantId("10000");
//        req.setRequestNo(UUID.randomUUID().toString().replaceAll("-", ""));
//        req.setServiceCode("admin");
//        List<String> to = new ArrayList<String>(){{
//           add("lvyongfh@163.com");
//        }};
//        req.setRecipients(to);
//        req.setTitle("测试邮件");
//        req.setContent("这是一个测试邮件！");
////        req.setTplId("");
////        req.setParam(Maps.newHashMap());
////        req.setFilePaths(Lists.newArrayList());
//
//        messageServiceApi.sendSimpleMail(req);
//    }
//
//    @GetMapping("ws/{clientId}")
//    public void ws(@PathVariable("clientId") String clientId) throws InterruptedException {
//        for (int i = 0; i < 20; i++) {
//            TopicInstancePush.sendMessage(clientId, "测试消息" + i);
//            Thread.sleep(1000);
//        }
//    }
//}
